﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Groupware;

namespace TripLOA.GUI
{
    public partial class WebForm1 : TripLOA.GUI.internationalization.LOABasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Browser["IsMobileDevice"] == "true" || Request.UserAgent.Contains("Opera Mobile")
                || Request.UserAgent.Contains("Opera Mini"))
            {
                Response.Redirect("m/MobileDefault.aspx");
            }
           user_val.Text = UserManager.getTotalRegisteredUsersCount()+ "";
            trips_val.Text = TripManager.getTotalCreatedTripsCount()+ "";
            HtmlGenericControl body = Master.FindControl("masterbody") as HtmlGenericControl;
           
            //System.Collections.Generic.List<Stats.RegisteredUser> listLastUser =  Groupware.UserManager.getLastFiveRegisteredUsers();
            //ListViewLastUserRegistered.DataSource = listLastUser;
            //ListViewLastUserRegistered.DataBind();

            //System.Collections.Generic.List<Stats.TripProperties> listTrips = Groupware.TripManager.getLastTenCreatedTrips();
            //ListViewLastTrips.DataSource = listTrips;
            //ListViewLastTrips.DataBind();

            ClientScriptManager manager = Page.ClientScript;
            double total_co2 = TripManager.getTripLOAEmissionsSaved();
            manager.RegisterStartupScript(this.GetType(), "Counter co2", "init('" + total_co2 + "');", true);
            
            }

        protected String Get_Gender(String gender)
        {
            if (gender.Equals("Female")) return "female";
            else if (gender.Equals("Male")) return "male";
            else return "unknow";
        }

        protected void OnClick_LastTrips(object sender, EventArgs e)
        {
            // DataKey a = ListViewLastTrips.SelectedDataKey;
            //String var = ((LinkButton)sender).CommandArgument;
        }
    }
}
